﻿using System.IO;
using System.Windows.Forms;
using System.Text;

namespace Layers
{


    public class DupTextWriter : TextWriter
    {
        private TextWriter A, B;

        public DupTextWriter(TextWriter a, TextWriter b)
        {
            A = a;
            B = b;
        }

        public override void Write(char[] buffer, int index, int count)
        {
            if (null != A)
                A.Write(buffer, index, count);
            if (null != B)
                B.Write(buffer, index, count);
        }

        public override void Write(char ch)
        {
            if (null != A)
                A.Write(ch);
            if (null != B)
                B.Write(ch);
        }

        private void Flush()
        {
            if (null != A)
                A.Flush();
            if (null != B)
                B.Flush();
        }

        public override Encoding Encoding
        {
            get { return null; }
        }
    }
}